package com.hksj.jetlinks.serialize;

import java.util.Collection;

public class ClassDescription {
    private final Class<?> type;
    private final boolean collectionType;
    private final boolean arrayType;
    private final boolean enumType;
    private final int fieldSize;
    private final boolean number;
    private final Object[] enums;

    public ClassDescription(Class<?> type) {
        this.type = type;
        this.collectionType = Collection.class.isAssignableFrom(type);
        this.arrayType = type.isArray();
        this.enumType = type.isEnum();
        this.fieldSize = type.getDeclaredFields().length;
        this.number = Number.class.isAssignableFrom(type);
        if (this.enumType) {
            this.enums = type.getEnumConstants();
        } else {
            this.enums = null;
        }

    }

    public Class<?> getType() {
        return this.type;
    }

    public boolean isCollectionType() {
        return this.collectionType;
    }

    public boolean isArrayType() {
        return this.arrayType;
    }

    public boolean isEnumType() {
        return this.enumType;
    }

    public int getFieldSize() {
        return this.fieldSize;
    }

    public boolean isNumber() {
        return this.number;
    }

    public Object[] getEnums() {
        return this.enums;
    }
}